// index.js
import {
  Request
} from '../../http/http.js'
Page({
  data: {
    // 轮播图
    slideList: [],
    // 文章列表
    articleList: [],
    // 人气推荐
    list: []

  },
  // 跳转文章详情
  articleClick(e) {
    // console.log(e);
    let id = e.currentTarget.dataset.item.id
    wx.navigateTo({
      url: '/pages/detail/detail?id=' + id,
    })
  },
  // 跳转人气推荐
  popularityClick() {
    wx.navigateTo({
      url: '/pages/popularity/popularity',
    })
  },
  // 跳转商品详情页
  figureClick(e) {
    console.log(e);
    let id=e.currentTarget.dataset.item.id
    console.log(id);
    wx.navigateTo({
      url: '/pages/goodsdetails/goodsdetails?id='+id,
    })
  },
  // 跳转签到页
  lotClick(){ 
wx.navigateTo({
  url: '/pages/lot/lot',
})
  },
  onLoad() {
    // 轮播图
    Request({url:'banner/list'}).then(res => {
      console.log(res);
      this.setData({
        slideList: res.data
      })
      // console.log(this.data.slideList);
    })
    // 文章列表
    Request({url:'cms/news/list'}).then(res => {
      console.log(res);
      this.setData({
        articleList: res.data
      })
      console.log(this.data.articleList);
    })
    // 人气推荐
    Request({url:'shop/goods/list'}).then(res => {
      this.data.list.push(res.data[9], res.data[10], res.data[11], res.data[12])
      this.setData({
        list: this.data.list
      })
    })
  },

})